﻿<!DOCTYPE HTML>
<html>
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>window.performance.timing when a persistent connection is used</title>
        <link rel="author" title="Google" href="http://www.google.com/" />
        <script src="/resources/testharness.js"></script>
        <script src="/webperf/tests/resources/webperftestharness.js"></script>
        <link rel="stylesheet" href="/resources/testharness.css" />

        <script type="text/javascript">
            setup({explicit_done: true});

            // explicitly test the namespace before we start testing
            test_namespace('timing');
 
            function onload_test()
            {
                var frame = document.getElementById("frameContext");
                var frame_timing = frame.contentWindow.performance.timing;
                test_equals(frame_timing.domainLookupStart, frame_timing.fetchStart,
                            'window.performance.timing.domainLookupStart == window.performance.timing.fetchStart');
                test_equals(frame_timing.domainLookupEnd, frame_timing.fetchStart,
                            'window.performance.timing.domainLookupEnd == window.performance.timing.fetchStart');
                test_equals(frame_timing.connectStart, frame_timing.fetchStart,
                            'window.performance.timing.connectStart == window.performance.timing.fetchStart');
                test_equals(frame_timing.connectEnd, frame_timing.fetchStart,
                            'window.performance.timing.connectEnd == window.performance.timing.fetchStart');
                done();
            }
        </script>
    </head>
    <body>
        <h1>Description</h1>
        <p>This test validates the values of window.performance.timing with a
        persistent connection.</p>

        <p>This page should be loaded with a green background frame below. The
        domainLookupStart, domainLookupEnd, connectStart and connectEnd should
        equal to fetchStart.</p>

        <p>Caveat: this test assumes all user agents with the NavigationTiming
        API will support persistent connection. And a persistent connection is
        always used between the user agent and the W3C test server.</p>

        <div id="log"></div>
        <br />
        <iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
        <script>
            var ifrm = document.getElementById("frameContext");
            // Add a timestamp to dodge the browser cache.
            var ts = new Date().getTime();
            ifrm.src = "/webperf/tests/resources/blank_page_green.htm?" + ts;
            ifrm.setAttribute("onload", "onload_test()");
        </script>


    </body>
</html>
